package com.woniuxy.mapper;

import com.work.framework.pojo.MoneyHistory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 〈一句话功能简述〉<br>
 * 〈金额流水表mapper〉
 *
 * @author jia
 * @create 2019/9/27
 * @since 1.0.0
 */
@Mapper
@Repository
public interface MoneyHistoryMapper {

    @Select("select * from money_history where flag = 1")
    List<MoneyHistory> findAll();

    @Select("SELECT SUM(price) FROM money_history WHERE flag=1 AND h_time LIKE '%${value}%' and h_type in (0,1,3)")
    Double selectMoneyByDay(String time);

    @Select("select SUM(price) from `money_history` where h_time > DATE_SUB(CURDATE(),INTERVAL 7 DAY) AND h_type=#{h_type}")
    Double selectMoneyByType(Integer h_type);


}
